Skip to content

helm: derive memcached's -m flag from resources overrides to prevent OOM kills - #16348

Open
bharathjyothi wants to merge 3 commits into
grafana:mainfrom
bharathjyothi:memcached-resources-9737
Open

helm: derive memcached's -m flag from resources overrides to prevent OOM kills#16348
bharathjyothi wants to merge 3 commits into
grafana:mainfrom
bharathjyothi:memcached-resources-9737

Conversation

@bharathjyothi

Copy link
Copy Markdown

What this PR does

Every memcached-backed cache (chunks-cache, index-cache, metadata-cache, results-cache) always
passed .allocatedMemory to memcached's own -m flag, even when a user overrode .resources with a
lower memory limit. That mismatch let memcached grow past the container's real memory limit and get OOM
killed.

This PR derives -m from resources.limits.memory (falling back to resources.requests.memory) when
.resources is overridden, using the existing mimir.siToBytes helper and the same 1.2x headroom ratio
the default path already uses. Behavior is unchanged when .resources isn't overridden.

Verified with helm template against every ci//ci/offline fixture (no diffs) plus a new regression
fixture, and end-to-end on a real cluster below.

Before/after on a live cluster (100Mi memory limit, 300MB write load)

Before: -m 8192 → pod OOMKilled (exit 137) after ~95MB written.

After: -m 83 → all 300MB written, 0 restarts, memcached self-manages via LRU eviction
(limit_maxbytes: 87031808 = 83MiB exactly, evictions: 218).

Which issue(s) this PR fixes or relates to

Fixes #9737

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

@cla-assistant

cla-assistant Bot commented Aug 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bharathjyothi
bharathjyothi marked this pull request as ready for review August 11, 2026 21:06
@bharathjyothi
bharathjyothi requested a review from a team as a code owner August 11, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to configure memcached container resources

1 participant